package com.campus.backend.controller;

import com.campus.backend.bean.statistics.StatisticsQueryParam;
import com.campus.backend.service.StatisticsService;
import com.campus.backend.vo.statistics.OrderStatisticsVo;
import com.campus.backend.vo.statistics.RevenueStatisticsVo;
import com.campus.common.bean.common.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 数据统计 控制器
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-05-21
 */
@Api(tags = "数据统计")
@RestController
@RequestMapping("/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    @ApiOperation("获取订单统计数据")
    @GetMapping("/order")
    public Resp<List<OrderStatisticsVo>> getOrderStatistics(@Valid StatisticsQueryParam param) {
        return Resp.success(statisticsService.getOrderStatistics(param));
    }

    @ApiOperation("获取商户营收分析数据")
    @GetMapping("/merchant-revenue")
    public Resp<List<RevenueStatisticsVo>> getMerchantRevenue(@Valid StatisticsQueryParam param) {
        return Resp.success(statisticsService.getMerchantRevenue(param));
    }

    @ApiOperation("获取平台营收分析数据")
    @GetMapping("/platform-revenue")
    public Resp<List<RevenueStatisticsVo>> getPlatformRevenue(@Valid StatisticsQueryParam param) {
        return Resp.success(statisticsService.getPlatformRevenue(param));
    }
}